//
// RTSPRequest.h
//
// $Id: //base/include/RTSPRequest.h
//
// Library: base
// Package: RTSP
// Module : RTSPRequest
// Author :	Jelin,doitsjz@163.com
// Date	  :	10/30/2012
// 
// Definition of the RTSPRequest class.
//
// Copyright (c) 2012-2012, iGuard.
//


#ifndef RTSPREQUEST_INCLUDED
#define RTSPREQUEST_INCLUDED
/*
		Request      =		Request-Line          ; Section 6.1
                    *(      general-header        ; Section 5
                    |       request-header        ; Section 6.2
                    |       entity-header )       ; Section 8.1
                            CRLF
                            [ message-body ]      ; Section 4.3
*/

/*
Request-Line = Method SP Request-URI SP RTSP-Version CRLF

   Method         =         "DESCRIBE"              ; Section 10.2
                  |         "ANNOUNCE"              ; Section 10.3
                  |         "GET_PARAMETER"         ; Section 10.8
                  |         "OPTIONS"               ; Section 10.1
                  |         "PAUSE"                 ; Section 10.6
                  |         "PLAY"                  ; Section 10.5
                  |         "RECORD"                ; Section 10.11
                  |         "REDIRECT"              ; Section 10.10
                  |         "SETUP"                 ; Section 10.4
                  |         "SET_PARAMETER"         ; Section 10.9
                  |         "TEARDOWN"              ; Section 10.7
                  |         extension-method
*/
/*
request-header  =          Accept                   ; Section 12.1
                  |          Accept-Encoding          ; Section 12.2
                  |          Accept-Language          ; Section 12.3
                  |          Authorization            ; Section 12.5
                  |          From                     ; Section 12.20
                  |          If-Modified-Since        ; Section 12.23
                  |          Range                    ; Section 12.29
                  |          Referer                  ; Section 12.30
                  |          User-Agent               ; Section 12.41				  
*/



#include "base.h"
#include "RTSPMessage.h"
/**
	RTSPRequest class for sending RTSP Request or recving RTSP Request
*/

class BASE_API RTSPRequest: public RTSPMessage
{
public:
	RTSPRequest();
	RTSPRequest(const std::string& version);
	RTSPRequest(const std::string& method, const std::string& uri);
	RTSPRequest(const std::string& method, const std::string& uri, const std::string& version);
	virtual ~RTSPRequest();

public:
	void setMethod(const std::string& method);
	const std::string& getMethod() const;
	void setURI(const std::string& uri);
	const std::string& getURI() const;
	void write(std::ostream& ostr) const;
	void read(std::istream& istr);
	void clear();

public:
	static const std::string DESCRIBE;
	static const std::string SETUP;
	static const std::string TEARDOWN;
	static const std::string PLAY;
	static const std::string PAUSE;
	static const std::string OPTIONS;
	static const std::string ANNOUNCE;
	static const std::string GET_PARAMETER;
	static const std::string SET_PARAMETER;
	static const std::string REDIRECT;
	static const std::string RECORD;
	static const std::string EMPTY;
	
	static const std::string HOST;
	static const std::string COOKIE;
	static const std::string AUTHORIZATION;

private:
	enum Limits
	{
		MAX_METHOD_LENGTH  = 32,
		MAX_URI_LENGTH     = 4096,	//4 KB
		MAX_VERSION_LENGTH = 8
	};
	
	std::string _method;
	std::string _uri;
	
	RTSPRequest(const RTSPRequest&);
	RTSPRequest& operator = (const RTSPRequest&);
};
//
// inlines
//
inline const std::string& RTSPRequest::getMethod() const
{
	return _method;
}


inline const std::string& RTSPRequest::getURI() const
{
	return _uri;
}


#endif